package com.example.lvsuo.service.impl;

import com.example.lvsuo.entity.vo.CaseLawVo;
import com.example.lvsuo.service.ICaseLawService;
import com.example.lvsuo.entity.CaseLaw;
import com.example.lvsuo.mapper.CaseLawMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 案件/我的案件    利益冲突审查    新增委托人    登记立案信息 服务实现类
 * </p>
 *
 * @author 心心念念
 * @since 2021-03-30
 */
@Service
@Transactional
public class CaseLawServiceImpl extends ServiceImpl<CaseLawMapper, CaseLaw> implements ICaseLawService {

    @Autowired
    CaseLawMapper cm;

    @Override
    public List<Map<String,Object>> queryCaseLaw(String caseOppositeCardnum, String cardnum) {
        return cm.queryCaseLaw(caseOppositeCardnum,cardnum);
    }

    @Override
    public String queryCaseNo() {
        return cm.queryCaseNo();
    }

    @Override
    public String queryId() {
        return cm.queryId();
    }

    @Override
    public PageInfo querySenior(CaseLawVo c) {
        if(c.getPageNum()==null){
            c.setPageNum(1);
        }
        if(c.getPageSize()==null){
            c.setPageSize(5);
        }
        PageHelper.startPage(c.getPageNum(),c.getPageSize());
        return new PageInfo(cm.querySenior(c));
    }

    @Override
    public void upCaseLaw(CaseLawVo c) {
        cm.upCaseLaw(c);
    }

    @Override
    public List<CaseLawVo> getCaseLaw(CaseLawVo caseLawVo) {
        return cm.getCaseLaw(caseLawVo);
    }
    
    public void updateLaw(String id) {
        CaseLawVo c=new CaseLawVo();
        c.setId(Integer.valueOf(id));
        List<CaseLawVo> vos = cm.queryAttorney(c);
        c.setCaseAttorney(vos.get(0).getCaseAttorney());
        cm.upCaseLaw(c);
    }

}
